package factory.simple.order;

import factory.simple.pizza.CheesePizza;
import factory.simple.pizza.GreekPizza;
import factory.simple.pizza.Pizza;

/**
 * @Author chenyeqing
 * @Date 2021/7/7 23:43
 */
public class SimpleFactory {

    /**
     * 根据 type 返回对应的 Pizza 对象
     * @param type
     * @return
     */
    public Pizza createPizza(String type) {

        Pizza pizza = null;

        System.out.println("使用了简单工厂");
        if ("greek".equals(type)) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if ("cheese".equals(type)) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        }

        return pizza;
    }
}
